package com.study.mirrorforest.main.model.entries.controller;


import com.study.mirrorforest.main.common.response.R;
import com.study.mirrorforest.main.model.entries.dto.CreateEntriesDTO;
import com.study.mirrorforest.main.model.entries.service.EntriesService;
import com.study.mirrorforest.main.model.entries.service.Impl.EntriesServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/entries")
public class EntriesController {

    @Autowired
    private EntriesServiceImpl entriesService;

    @PostMapping("/create")
    public R CreateEntry(@RequestBody CreateEntriesDTO entry) {
        System.out.println(entry);
        return entriesService.CreateEntry(entry);
    }

    @GetMapping("/list")
    public R GetEntryList(@RequestParam Long userId,
                          @RequestParam(required = false) String title)
    {
        System.out.println(userId);
        System.out.println(title);
        return entriesService.GetEntryList(userId,title);
    }

}
